// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import router from './router'
import store from './store/index'
import App from './App'
import {WechatPlugin, AjaxPlugin, ConfirmPlugin , ToastPlugin, AlertPlugin,querystring} from 'vux'

import VueClipboard from 'vue-clipboard2'


// 图片懒加载
import VueLazyload from 'vue-lazyload'
import '@/assets/alifont/iconfont.css'
import VueBarcode from '@xkeshi/vue-barcode'; //导入条形码插件
Vue.component('barcode', VueBarcode);  //声明条形码组件


//fastclick：处理移动端click事件300毫秒延迟
//绑定到body
FastClick.attach(document.body)

Vue.config.productionTip = false
Vue.use(ConfirmPlugin)

Vue.use(WechatPlugin)
Vue.use(AjaxPlugin)

Vue.use(ToastPlugin)
Vue.use(AlertPlugin)

// Vue.prototype.$http.defaults.baseURL ='http://www.gxmisi.com:8088/v1/api/';
Vue.prototype.$http.defaults.baseURL ='http://127.0.0.1:8089/v1/api/';
// Vue.prototype.$http.defaults.baseURL ='http://192.168.1.21:8089/v1/api/';
// Vue.prototype.$http.defaults.baseURL ='http://testmisi.gxmisi.com/v1/api/';


Vue.use(VueLazyload)
//剪贴板
Vue.use(VueClipboard)

Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.innerText==null?'淘美味': el.innerText
    el.remove()
  }
})


router.beforeEach((to,from,next)=>{
  if(store.getters.getOpenId==null && to.path!="/" && to.name!="Wxlogin"){
    localStorage.setItem("beforeUrl",to.path);
    next("/Wxlogin/null");
    return false;
  }
  if(store.getters.getMemberPtId!=0 &&to.name == "Wxlogin"){
    WeixinJSBridge.call("closeWindow");
  }
  next();

})




/* eslint-disable no-new */
new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app-box')
